#include <iostream>
#include <tr1/array>
using namespace std;


//int array[6] = {1,2,3,4,5,6};
char array[] = {'a', 'b', 'c', 'd', 'e', 'f'};
int num = 0;
int size = 6;
   
void swap(int x, int y){
  char temp = array[x];
  array[x] = array[y];
  array[y] = temp;
}

void perm(int k)
 {
   if (k == 0){
     num++;
     for (int i=0; i<size; i++)
       cout << array[i] << " ";
     cout << endl;
   }
   else{
     for (int j=k-1; j>=0; j--){
       swap(j, k-1);
       perm(k-1);
       swap(j, k-1);
     }
   }
 }
 
  
int main()
 {
   perm(6); 
   cout << "------------------" << endl;
   cout << "\nNumber of permutations: " << num << endl;
 }
        